#!/bin/sh

copy_link_file()
{
	echo "check file $1/$2"
	
	FILE=$1/$2
	mkdir -p tmp/$1
	cp -av $FILE tmp/$FILE

	LINKFILE=`readlink $FILE`
	if [ "$?" = 0 ]; then
		echo "link to => $LINKFILE"
		DIRNAME=$1
		BASENAME=`basename $LINKFILE`
		copy_link_file $DIRNAME $BASENAME
	else
		echo "nolink file $FILE"
	fi
}

CP_DIRNAME=`dirname $1`
CP_BASENAME=`basename $1`
copy_link_file $CP_DIRNAME $CP_BASENAME

exit 0

